package com.yunfei.api.v2.service;

import com.yunfei.api.v2.param.HeTongSignInfoGetStatusParam;
import com.yunfei.api.v2.result.HeTongSignInfoGetStatusResult;
import com.yunfei.bo.result.ResultModel;
import com.yunfei.enums.HeTongSignInfoGetStatusResultStatus;
import com.yunfei.enums.ResultStatus;
import com.yunfei.mapper.aiiidb.HeTongSignInfoMapper;
import com.yunfei.utils.string.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class HTSGetStatusService {
    @Autowired
    private HeTongSignInfoMapper heTongSignInfoMapper;
    public ResultModel getStatus(HeTongSignInfoGetStatusParam param){
        ResultModel resultModel=new ResultModel();
        Map<String,Object> queryMap=new HashMap<>();
        try{
            String reserveNo=param.getReserveNo();//预约编号
            if(StringUtil.isNullOrEmpty(reserveNo)){
                resultModel.setCode(HeTongSignInfoGetStatusResultStatus.RESERVENO_NOTNULL.getCode());
                resultModel.setMessage(HeTongSignInfoGetStatusResultStatus.RESERVENO_NOTNULL.getMessage());
                return resultModel;
            }
            queryMap.put("reserveNo",reserveNo);
            String status=heTongSignInfoMapper.getStatus(queryMap);
            HeTongSignInfoGetStatusResult heTongSignInfoGetStatusResult=new HeTongSignInfoGetStatusResult();
            heTongSignInfoGetStatusResult.setStatus(status);
            resultModel.setData(heTongSignInfoGetStatusResult);
            resultModel.setCode(ResultStatus.SUCCESS.getCode());
            resultModel.setMessage(ResultStatus.SUCCESS.getMessage());
        }catch (Exception e){
            resultModel.setCode(ResultStatus.ERROR.getCode());
            resultModel.setMessage(ResultStatus.ERROR.getMessage());
            e.printStackTrace();
        }
        return resultModel;
    }
}
